#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int main() {
    int n = 0;
    int m = 0;
    int arr1[2000];
    scanf("%d %d", &n, &m);
   
    for (int i = 0; i < n; i++)
            scanf("%d", &arr1[i]);
    for (int i = n; i < m + n; i++)
            scanf("%d", &arr1[i]);
    for (int i = 0; i < m + n - 1; i++)
    {
        for (int j = 0; j < m + n - 1 - i; j++)
        {
           if (arr1[j] > arr1[j + 1])
           {
            int temp = arr1[j];
            arr1[j] = arr1[j + 1];
            arr1[j + 1] = temp;

            }
        }
    }
    for (int i = 0; i < m + n; i++)
    {
        printf("%d ", arr1[i]);
    }
    printf("\n");

    return 0;
}